package com.atguigu.multiReading;

import java.util.Arrays;

public class demo11 {
    public static void main(String[] args){
        int[] array=new int[]{2,7,4,1,8,1};
        while(array.length>1){
            int l=array.length;
            Arrays.sort(array);
            if(array[l-1]==array[l-2]){
                int[] newArray=new int[l-2];
                for(int i=0;i< newArray.length;i++){
                    newArray[i]=array[i];
                }
                array=newArray;
            }else{
                int[] newArray=new int[l-1];
                for(int i=0;i<l-2;i++){
                    newArray[i]=array[i];
                }
                newArray[l-2]=Math.abs(array[l-1]-array[l-2]);
                array=newArray;
            }
        }
        if(array.length==1){
            System.out.println(array[0]);
        }else{
            System.out.println(0);
        }
    }
}
